home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gssubst < prev    next >
Encoding:
Tcl/Tk script  |  2001-01-01  |  675 b   |  24 lines

  1. #!/usr/bin/tclsh
  2. # $Id: gssubst,v 1.1 2000/03/09 08:40:42 lpd Exp $
  3. if {$argc < 2} {
  4.     puts stderr "Usage: $argv0 (-t type | -u word | fromword toword) file ..."
  5.     puts stderr "  -t word = word word_t"
  6.     puts stderr "  -u word = word WORD"
  7.     exit 1
  8. }
  9. set a0 [lindex $argv 0]
  10. set a1 [lindex $argv 1]
  11. switch -- $a0 {
  12.     -t {set from $a1; set to ${from}_t}
  13.     -u {set from $a1; set to [string toupper ${from}]}
  14.     default {set from $a0; set to $a1}
  15. }
  16. puts "$from => $to"
  17. flush stdout
  18. set tmp /tmp/[pid]
  19. foreach f [lreplace $argv 0 1] {
  20.     if {![file exists $f~]} {exec cp -p $f $f~}
  21.     exec perl -pe "s\{\\b${from}\\b\}\{${to}\}g" < $f > $tmp
  22.     exec mv $tmp $f
  23. }
  24.